package com.example.om_export.system.log.service;


import com.example.om_export.common.entity.Params;
import com.example.om_export.common.entity.Result;
import com.example.om_export.system.log.dao.OptLoggerMapper;
import com.example.om_export.system.log.entity.OptLogger;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class OptLogService {

    @Autowired
    private OptLoggerMapper optLoggerMapper;

    public Result addOptLogger(OptLogger record) {
        return Result.byRow(optLoggerMapper.insert(record));
    }

    /**
     * 获取日志列表
     * @param params
     * @return
     */
    public Result getList(Params params) {
        Integer page = params.getInt("page");
        Integer limit = params.getInt("limit");
        Page<Object> pageInfo = PageHelper.startPage(page, limit);
        optLoggerMapper.selectAll(params);
        return Result.byPage(pageInfo);
    }

}
